import java.awt.Graphics;


public abstract class Building {
	private int lumberCost;
	private int woolCost;
	private int brickCost;
	private int oreCost;
	private int grainCost;
	
	/*
	 * Checks that the player has appropriate resources for the desired building. If so, calls construct method to build building
	 * then subtracts resources and returns true. If player fails to construct or has insufficient resources, @returns false.
	 */
	public boolean build (Player player){
		if (player.getWool() >= woolCost && player.getLumber() >= lumberCost && player.getBrick() >= brickCost
				&& player.getOre() >= oreCost && player.getGrain() >= grainCost){
			if(construct(player)){
				player.addWool(-woolCost);
				player.addLumber(-lumberCost);
				player.addBrick(-brickCost);
				player.addOre(-oreCost);
				player.addGrain(-grainCost);
				return true;
			}
		}
		return false;
	}
	
	protected abstract void drawSelf(Graphics g);
	
	protected abstract boolean construct(Player player);
		/* Implementation should force the player to place the building in an appropriate place. If no appropriate place or player
		 * cancels build, return false. If successfully placed, return true;
		 */
	
	public int getLumberCost() {
		return lumberCost;
	}
	public void setLumberCost(int lumberCost) {
		this.lumberCost = lumberCost;
	}
	public int getWoolCost() {
		return woolCost;
	}
	public void setWoolCost(int woolCost) {
		this.woolCost = woolCost;
	}
	public int getBrickCost() {
		return brickCost;
	}
	public void setBrickCost(int brickCost) {
		this.brickCost = brickCost;
	}
	public int getOreCost() {
		return oreCost;
	}
	public void setOreCost(int oreCost) {
		this.oreCost = oreCost;
	}
	public int getGrainCost() {
		return grainCost;
	}
	public void setGrainCost(int grainCost) {
		this.grainCost = grainCost;
	}
	
	
	
}
